//
//  ZSY_DestinationListCollectionViewCell.m
//  zsy_BreadTrip
//
//  Created by dllo on 15/12/28.
//  Copyright © 2015年 dllo. All rights reserved.
//

#import "ZSY_DestinationListCollectionViewCell.h"

@interface ZSY_DestinationListCollectionViewCell ()

@property (nonatomic, retain) ZSY_BaseImageView *coverImageView;
@property (nonatomic, retain) ZSY_BaseLabel *nameLabel;

@end

@implementation ZSY_DestinationListCollectionViewCell

- (void)dealloc {
    [_destination release];
    [_coverImageView release];
    [_nameLabel release];
    [super dealloc];
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

- (void)setDestination:(ZSY_DestinationModel *)destination {
    if (_destination != destination) {
        [_destination release];
        _destination = [destination retain];
    }
    
    NSLog(@"name = %@", _destination.name);
    self.nameLabel.text = _destination.name_orig;
    self.nameLabel.textColor = [UIColor whiteColor];
    
    NSURL *url = [NSURL URLWithString:_destination.cover];
    [self.coverImageView sd_setImageWithURL:url placeholderImage:nil];
    
    
}

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self createSubviews];
    }
    return self;
}

- (void)createSubviews {
//    self.contentView.backgroundColor = [UIColor colorWithRed:248 / 255.0 green:243 / 255.0 blue:233 / 255.0 alpha:1];
    
    self.contentView.layer.borderColor = [UIColor lightGrayColor].CGColor;
    self.contentView.layer.borderWidth = 1;
    self.contentView.layer.cornerRadius = 5;
    self.contentView.layer.masksToBounds = YES;
    
    self.coverImageView = [[ZSY_BaseImageView alloc] initWithFrame:CGRectMake(0, 0, (WIDTH - 30) / 2, 180)];
//    self.coverImageView.backgroundColor = [UIColor blackColor];
    self.coverImageView.layer.cornerRadius = 5;
    self.coverImageView.layer.masksToBounds = YES;
    [self.contentView addSubview:_coverImageView];
    
    self.nameLabel = [[ZSY_BaseLabel alloc] initWithFrame:CGRectMake(10, 150, 100, 20)];
//    self.nameLabel.backgroundColor = [UIColor lightGrayColor];
    [self.coverImageView addSubview:_nameLabel];

}

@end
